from mediator import mediator
from mediator . tests . test_assistant import make_mediator_test_keyword_args

class gui_fake :
    def __init__ ( self ) :
        self . _gui_create_text_request = None
        self . _gui_enable_text_edit = None
        self . _gui_disable_text_edit = None
        self . _gui_add_string_to_text_widget = None
        self . _gui_add_mark_to_text_widget = None
        self . _gui_add_widget_to_text_widget = None
        self . _gui_remove_widget_from_text_widget = None
        self . _gui_remove_mark_from_text_widget = None
        self . _gui_delete_text_from_mark_to_end_of_text_widget = None
    def gui_create_text_request ( self , master ) :
        self . _gui_create_text_request = master
    def gui_enable_text_edit ( self , text_widget ) :
        self . _gui_enable_text_edit = text_widget
    def gui_disable_text_edit ( self , text_widget ) :
        self . _gui_disable_text_edit = text_widget
    def gui_add_string_to_text_widget ( self , text_widget , string ) :
        self . _gui_add_string_to_text_widget = [ text_widget , string ]
    def gui_add_mark_to_text_widget ( self , text_widget , mark ) :
        self . _gui_add_mark_to_text_widget = [ text_widget , mark ]
    def gui_add_widget_to_text_widget ( self , text_widget , widget ) :
        self . _gui_add_widget_to_text_widget = [ text_widget , widget ]
    def gui_remove_widget_from_text_widget ( self , text_widget , widget ) :
        self . _gui_remove_widget_from_text_widget = [ text_widget , widget ]
    def gui_remove_mark_from_text_widget ( self , text_widget , mark ) :
        self . _gui_remove_mark_from_text_widget = [ text_widget , mark ]
    def gui_delete_text_from_mark_to_end_of_text_widget ( self , text_widget , mark ) :
        self . _gui_delete_text_from_mark_to_end_of_text_widget = [ text_widget , mark ]

class mediator_gui_text_tests : 
    'mediator_gui_text'
    def __init__ ( self , test ) :
        self . _test = test
        self . _gui = gui_fake ( )
        self . _mediator = mediator ( )
        self . _mediator . register_modules ( ** make_mediator_test_keyword_args \
            ( 'gui' 
            , self . _gui 
            , None
            ) )
    def test_gui_create_text_request ( self ) :
        self . _mediator . gui_create_text_request ( 'my master' )
        self . _test . assume_equal ( self . _gui . _gui_create_text_request , 'my master' )
    def test_gui_enable_text_edit ( self ) :
        self . _mediator . gui_enable_text_edit ( 'my widget' )
        self . _test . assume_equal ( self . _gui . _gui_enable_text_edit , 'my widget' )
    def test_gui_disable_text_edit ( self ) :
        self . _mediator . gui_disable_text_edit ( 'my widget' )
        self . _test . assume_equal ( self . _gui . _gui_disable_text_edit , 'my widget' )
    def test_gui_add_string_to_text_widget ( self ) :
        self . _mediator . gui_add_string_to_text_widget ( 'my widget' , 'my string' )
        self . _test . assume_equal ( self . _gui . _gui_add_string_to_text_widget , [ 'my widget' , 'my string' ] )
    def test_gui_add_mark_to_text_widget ( self ) :
        self . _mediator . gui_add_mark_to_text_widget ( 'my widget' , 'my mark' )
        self . _test . assume_equal ( self . _gui . _gui_add_mark_to_text_widget , [ 'my widget' , 'my mark' ] )
    def test_gui_add_widget_to_text_widget ( self ) :
        self . _mediator . gui_add_widget_to_text_widget ( 'my text widget' , 'my widget' )
        self . _test . assume_equal ( self . _gui . _gui_add_widget_to_text_widget , [ 'my text widget' , 'my widget' ] )
    def test_gui_remove_widget_from_text_widget ( self ) :
        self . _mediator . gui_remove_widget_from_text_widget ( 'my text widget' , 'my widget' )
        self . _test . assume_equal ( self . _gui . _gui_remove_widget_from_text_widget , [ 'my text widget' , 'my widget' ] )
    def test_gui_remove_mark_from_text_widget ( self ) :
        self . _mediator . gui_remove_mark_from_text_widget ( 'my widget' , 'my mark' )
        self . _test . assume_equal ( self . _gui . _gui_remove_mark_from_text_widget , [ 'my widget' , 'my mark' ] )
    def test_gui_delete_text_from_mark_to_end_of_text_widget ( self ) :
        self . _mediator . gui_delete_text_from_mark_to_end_of_text_widget ( 'my widget' , 'my mark' )
        self . _test . assume_equal ( self . _gui . _gui_delete_text_from_mark_to_end_of_text_widget , [ 'my widget' , 'my mark' ] )
